import com.shihan.config.RabbitMQConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;

import java.io.UnsupportedEncodingException;

/**
 * @Description
 * @Author shihan
 * @Date 2020/12/26 17:48
 * @Version 1.0
 */
public class App {

    public static void main(String[] args) throws UnsupportedEncodingException {

        AbstractApplicationContext context = new AnnotationConfigApplicationContext(RabbitMQConfig.class);

        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);

        // 主动拉取消息 进行消费
        Message message = rabbitTemplate.receive("");

        System.out.println("接收到的消息为：" + new String(message.getBody(),message.getMessageProperties().getContentEncoding()));

    }

}
